#include <windows.h>
#include "Header.h"

int main()
{
    IDog* lpDog = nullptr;
    ICat* lpCat = nullptr;
    IPig* lpPig = nullptr;
    HRESULT hResult;

    CoInitialize(nullptr);

    do
    {
        hResult = CoCreateInstance(CLSID_ANIMALS, nullptr, CLSCTX_INPROC, 
            IID_IDog, (void**)&lpDog);
        if (S_OK != hResult) break;

        hResult = CoCreateInstance(CLSID_ANIMALS, nullptr, CLSCTX_INPROC, 
            IID_ICat, (void**)&lpCat);
        if (S_OK != hResult) break;

        hResult = CoCreateInstance(CLSID_ANIMALS, nullptr, CLSCTX_INPROC, 
            IID_IPig, (void**)&lpPig);
        if (S_OK != hResult) break;

        lpDog->Woof((const unsigned char*)"Hello\r\n");
        lpCat->Meow((const unsigned char*)"Hello\r\n");
        lpPig->Oink((const unsigned char*)"Hello\r\n");

    } while (FALSE);

    if (lpPig)
    {
        lpPig->Release();
    }

    if (lpCat)
    {
        lpCat->Release();
    }

    if (lpDog)
    {
        lpDog->Release();
    }

    CoFreeUnusedLibraries();

    CoUninitialize();

    return 0;
}